import axios from "axios";
import { put, takeEvery } from "redux-saga/effects";
import { getHotSongsFailed, getHotSongsSuccess, GET_HOTSONGS, IGetHotSongsAction } from "../actions/hotsongs.action";

function* handleGetHotSongs (action: IGetHotSongsAction) {
  try {
    const { data } = yield axios.get('http://localhost:3000/api/playlist/detail?id=3778678')
    console.log("hot songs--->", data, action);
    yield put(getHotSongsSuccess(data))
  } catch (error) {
    yield put(getHotSongsFailed(JSON.stringify(error)))
  }
}

export default function* hotSongsSaga () {
  yield takeEvery(GET_HOTSONGS, handleGetHotSongs)
}